package ${package.Controller};

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
 import org.springframework.web.bind.annotation.RestController;
<#else>
 import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
 import ${superControllerClassPackage};
</#if>
import org.springframework.beans.factory.annotation.Autowired;
import ${package.Service}.${table.serviceName};
<#--import ${package.Entity}.${table.entityName};-->
import org.springframework.web.bind.annotation.*;
import com.atguigu.yygh.common.result.Result;

/**
* <p>
 * ${table.comment!} 前端控制器
 * </p>
*
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
 @RestController
<#else>
 @Controller
</#if>
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
 class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
 <#if superControllerClass??>
  public class ${table.controllerName} extends ${superControllerClass} {
 <#else>
  public class ${table.controllerName} {
 </#if>
    @Autowired
    private ${table.serviceName} ${table.entityPath}Service;


    @DeleteMapping("/{id}")
    public Result deleteByID(Long id) {
       return ${table.entityPath}Service.delete${entity}(id);
    }

    @PostMapping("/saveModel")
    public Result insert(@RequestBody ${entity} ${table.entityPath}) {
       return ${table.entityPath}Service.insert${entity}(${table.entityPath});

    }

    @PutMapping("/updateModel")
    public Result update(@RequestBody ${entity} ${table.entityPath}) {
       return ${table.entityPath}Service.update${entity}(${table.entityPath});
    }
}
</#if>

